package com.atguigu.crowd.service.impl;

import com.atguigu.crowd.entity.po.MemberPO;
import com.atguigu.crowd.entity.po.ProjectPO;
import com.atguigu.crowd.entity.vo.MemberVO;
import com.atguigu.crowd.entity.po.MemberPOExample;
import com.atguigu.crowd.entity.vo.ProjectVO;
import com.atguigu.crowd.mapper.MemberPOMapper;
import com.atguigu.crowd.service.api.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author zzqstart
 * @Description
 * @date 2022-09-16 13:39
 */
@Transactional(readOnly = true)
@Service
public class MemberServiceImpl implements MemberService {
    @Autowired
    private MemberPOMapper memberPOMapper;

    @Override
    public MemberVO getMemberPOByLoginAcctRemote(String loginacct) {
        MemberPOExample memberPOExample = new MemberPOExample();
        memberPOExample.createCriteria().andLoginacctEqualTo(loginacct);
        List<MemberVO> memberPOS = memberPOMapper.selectByExample(memberPOExample);
        if (memberPOS == null || memberPOS.size() == 0){
            return null;
        }
        return memberPOS.get(0);
    }

    @Transactional(readOnly = false)
    @Override
    public void saveMemberpoToRegistAcctRemote(MemberPO memberPO) {
        memberPOMapper.insertSelective(memberPO);
    }

}
